package com.ttpai.boot.lbs.dao;

import com.ttpai.boot.lbs.model.MetroPointTimeVO;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;

import java.util.List;

@DAO
public interface MetroPointTimeDAO {

    String ALL_FIELD = "CITY_NAME,ORIGIN,DISTINATION,USE_TIME,BD_INFO";

    @SQL("SELECT " + ALL_FIELD + " FROM _KAIL_METRO_POINT_TIME WHERE 1=1" +
            " #if(null!=:p.cityName && ''!=:p.cityName){ AND CITY_NAME LIKE :p.cityName}" +
            " #if(null!=:p.origin && ''!=:p.origin){ AND ORIGIN = :p.origin}" +
            " #if(null!=:p.distination && ''!=:p.distination){ AND DISTINATION = :p.distination}" +
            " ORDER BY ID")
    List<MetroPointTimeVO> selectAllMetroPoint(@SQLParam("p") MetroPointTimeVO p);


    @SQL("REPLACE INTO _KAIL_METRO_POINT_TIME (" + ALL_FIELD + ") VALUES (:mp.cityName,:mp.origin,:mp.distination,:mp.useTime,:mp.bdInfo)")
    Integer insertMetroPoint(@SQLParam("mp") MetroPointTimeVO metroPoint);

    @SQL("REPLACE INTO _KAIL_METRO_POINT_TIME (" + ALL_FIELD + ") VALUES (:mp.cityName,:mp.origin,:mp.distination,:mp.useTime,:mp.bdInfo)")
    Integer insertMetroPointList(@SQLParam("mp") List<MetroPointTimeVO> metroPoint);


}
